home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / swaga-c / copymove.swg / 0015_Move File with Rename.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  863b  |  29 lines

  1. {
  2. │ I am interested in the source in Asm or TP to move a File from one
  3. │ directory to another by means of the FAT table.
  4.  
  5. All you have to do is use the Rename Procedure.  It isn't done via the
  6. FAT table, but via Dos Function 56h.  The only restrictions are (1)
  7. you must be running on Dos 2.0 or greater, and (2) the original and
  8. target directories must be on the same drive.  The code might look
  9. something like this:
  10. }
  11.  
  12. Function MoveFile( FileName, NewDir: Dos.PathStr ): Boolean;
  13. Var
  14.   f:      File;
  15.   OldDir: Dos.DirStr;
  16.   Nam:    Dos.NameStr;
  17.   Ext:    Dos.ExtStr;
  18. begin
  19.   Dos.FSplit( FileName, OldDir, Nam, Ext );
  20.   if NewDir[ Length(NewDir) ] <> '\' then
  21.     NewDir := NewDir + '\';
  22.   {$I-}
  23.   Assign( f, FileName );
  24.   FileName := NewDir + Nam + Ext;
  25.   Rename( f, FileName );
  26.   MoveFile := (Ioresult=0);
  27.   {$I+}
  28. end; { MoveFile }
  29.